<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>报损报溢打印</title>
    <script src="/jquery-1.8.3.min.js"></script>
    <script src="/printThis.js"></script>
    <script src="/chineseMoney.js"></script>
    <script src="/tools.js"></script>
    <link rel="stylesheet" href="/print.css"/>
</head>
<body>
<div id="receiptPrintArea0">
    <h3 style="text-align: center">报损报溢汇总表<span class="originalProcess"></span></h3>
    <br/>
    <table width="100%">
        <tr>
            <td width="25%">入库日期范围：</td><td width="75%"><span class="stockDate"></span></td>
        </tr>
        <tr>
            <td width="25%">食材类型：</td><td width="75%"><span class="type"></span></td>
        </tr>
    </table>
    <br/>
    <table style="width: 100%;" class="printTable">
        <thead style="border: 1px solid">
        <td width="35%">名称</td>
        <td width="20%">规格</td>
        <td width="20%">品牌</td>
        <td width="10%">单位</td>
        <td width="15%">数量</td>
        </thead>
        <tbody id="content">
        </tbody>
    </table>
</div>
<script th:inline="javascript">
    var params = [[${params}]];
    var backAddress = params.backAddress;
    var beginStockDate = params.beginStockDate;
    var endStockDate = params.endStockDate;
    var foodMaterialType = params.foodMaterialType;
    var foodMaterialTypeName = params.foodMaterialTypeName;
    var originalProcess = params.originalProcess;
    function print() {
        $("#receiptPrintArea0").printThis({
            debug: false,
            importCSS: true,
            importStyle: true,
            printContainer: true,
            pageTitle: "",
            removeInline: false,
            printDelay: 333,
            header: null,
            formValues: true
        });
    }
    $.ajax({
        url: backAddress + "/api/financial/queryProfitAndLoss",
        type: "post",
        dataType: "json",
        contentType: "application/json;charset=utf-8",
        data : JSON.stringify({
            "beginStockDate" : beginStockDate,
            "endStockDate" : endStockDate,
            "foodMaterialType" : foodMaterialType,
            "originalProcess" : originalProcess,
            "pageNo" : 1,
            "pageSize" : 2000
        }),
        success: function (data) {
                //console.log(data)
            $(".stockDate")[0].innerText = beginStockDate + '至' + endStockDate;
            $(".type")[0].innerText = foodMaterialTypeName;
            $(".originalProcess")[0].innerText = getOriginalProcess(originalProcess);
            var str = '' ;
            for (var i = 0 ; i < data.data.list.length ; i++) {
                str = "<tr><td width=\"35%\">" + data.data.list[i].foodMaterialName + "</td>" +
                    "<td width=\"20%\">" + dealNull(data.data.list[i].specs) + "</td>" +
                    "<td width=\"20%\">" + dealNull(data.data.list[i].brand) + "</td>" +
                    "<td width=\"10%\">" + dealNull(data.data.list[i].unitName) + "</td>" +
                    "<td width=\"15%\">" + data.data.list[i].amount + "</td></tr>" ;
                $("#content").append($(str));
            }
            print()
        },
        error: function (status) {
            alert(status)
        }
    })
</script>
</body>
</html>